import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class SortPoker {
    //这里是对发的牌进行排序
    static HashMap<Integer, String> poker = new HashMap<>();
    static ArrayList<Integer> list = new ArrayList<>();

    static {
        //创建牌盒存入牌的数据
        String[] color = {"♦", "♣", "♥", "♠"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        int count = 1;
        for (String n : number) {
            for (String c : color) {
                list.add(count);
                poker.put(count, c + n);
                count++;
            }
        }
        //添加好数据后还需要添加大小王
        poker.put(count, "大王");
        list.add(count);
        count++;
        poker.put(count, "小王");
        list.add(count);

    }

    public SortPoker() {
        Collections.shuffle(list);
        //这里创建底牌盒三位玩家的牌的集合
        TreeSet<Integer> lord = new TreeSet<>();
        TreeSet<Integer> gamer1 = new TreeSet<>();
        TreeSet<Integer> gamer2 = new TreeSet<>();
        TreeSet<Integer> gamer3 = new TreeSet<>();
        for (int i = 0; i < list.size(); i++) {
            int j = list.get(i);
            if (i <= 2) {
                lord.add(j);
            } else if (i % 3 == 0) {
                gamer1.add(j);
            } else if (i % 3 == 1) {
                gamer2.add(j);
            } else {
                gamer3.add(j);
            }
        }
        lookPoker("底牌", lord);
        lookPoker("Jack", gamer1);
        lookPoker("Tom", gamer2);
        lookPoker("Mary", gamer3);

    }

    public static void lookPoker(String name, TreeSet<Integer> ts) {
        System.out.print(name + " : ");
        for (int n : ts) {
            System.out.print(poker.get(n) + " ");
        }
        System.out.println();
    }

}


